<template>
  <div>
    <Tou></Tou>
    <Second></Second>
      <span style="font-size: 14px;margin-left: -800px">您现在的位置：客运首页  > 注册</span>
    <div style="width: 1000px;height: 600px;margin: 0 auto;border: 1px solid #418CCD">
      <div style="background-color: #418CCD;height: 30px;">
        <span style="color: white; display: flex;margin-left: 30px">账户信息</span><br>
        <span style="font-size: 14px">用户名</span><el-input v-model="userList.userName"  placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 39px"></el-input><br>
        <span style="font-size: 14px">登陆密码</span><el-input  v-model="userList.userPass" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 26px;"></el-input><br>
        <span style="font-size: 14px">确认密码</span><el-input v-model="rePass" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 29px;"></el-input><br>
        <span style="font-size: 14px">证件类型</span><el-input  placeholder="请输入内容" value="中国居民身份证" style="width: 500px;margin-top: 10px;margin-left: 30px;" readonly></el-input><br>
        <span style="font-size: 14px">姓名</span><el-input v-model="userList.userRelname" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 60px;"></el-input><br>
        <span style="font-size: 14px">证件号码</span><el-input v-model="userList.userCare" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 33px"></el-input><br>
        <template>
          <div>
            <span style="font-size: 14px">优惠(待)类型</span>
            <el-select v-model="userList.userFlag" placeholder="请选择" style="width: 500px;margin-top: 10px;margin-left: 10px">
              <el-option
                v-for="item in aaa "
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
        </template>
        <hr class="dashed">
        <span style="font-size: 14px;margin-left: 7px">邮箱</span><el-input v-model="userList.userMail" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 50px"></el-input><br>
        <span style="font-size: 14px;margin-left: -31px">验证码</span><el-input v-model="userList.code" placeholder="请输入内容" style="width: 300px;margin-top: 10px;margin-left: 40px"></el-input>
        <el-button type="primary" style="margin-left: 50px" @click="tosend(userList.userMail)">发送验证码</el-button><br>
        <span style="font-size: 14px">手机号码</span><el-input v-model="userList.userTel" placeholder="请输入内容" style="width: 500px;margin-top: 10px;margin-left: 30px"></el-input><br>
        <el-checkbox style="margin-top: 20px;" @change="judgments">我已阅读并同意遵守 <span style="color: #5199FD">《中国铁路客户服务中心网站服务条款》 《隐私权政策》</span></el-checkbox><br>
        <el-button style="background-color: #F58100;color: white;margin-top: 10px" round @click="toregist()">提交注册</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import Tou from "./tou.vue";
import Second from "./second.vue";
export default {
  name: "zhuce",
  components: {Second, Tou},
  data(){
    return{
      rePass:'',
      userList:{
        userId:'',
        userName:'',
        userPass:'',
        userRelname:'',
        userCare:'',
        userMail:'',
        userTel:'',
        userFlag:'',
        userVip:'',
        code:''
      },
      aaa:[
        {
          value: 1,
          label: '学生'
        },
        {
        value: 0,
          label: '成人'
        },
        {
          value: 2,
          label: '儿童'
        }
      ],
      judgment:false
    }
  },
  methods:{
    judgments(){
       this.judgment=true;
    },
    tosend(userMail){
      this.$axios.get('/user/sendmail',{
        params:{
          userMail:userMail
        }
      }).then(res=>{
        if (res.data.code==200)
          alert("发送成功")
      })
    },
    toregist(){
      if (this.judgment) {
        if (this.userList.userPass != this.rePass)
          alert("两次密码不一致,请重新输入")
        else {
          this.$axios.post('/user/regist', this.userList)
            .then(res => {
              if (res.data.code == 200) {
                alert("注册成功")
                this.$router.push('/login')
              } else if (res.data.code == 202) {
                alert(res.data.msg)
              }
            })
        }
      }else
        alert("请先勾选按钮,再注册")
    }
  }
}
</script>

<style scoped>
hr.dashed {
  border: none;
  border-top: 2px dashed #999; /* 设置虚线样式 */
}
</style>
